<?=$this->header()?>


    <?=$this->menu("guides")?>


    <h1><?=$this->message("nav.guides")?></h1>


    <? /* Breadcrums route & guide info display */ ?>
    <?=$this->route(
        $this->message("nav.guides"),           // Route display
        $this->guideListForm,                           // ListForm (for guide info, see float right)
        $this->guides($this->guideListForm)->getRows()) // The total amount of guides
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->guideListForm)?>"
          method="post"
          action="guide/list"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "guide/edit",         // Add New URL
            $this->guideListForm, // ListForm
            array(                // Filter fields
                GuideI18nPeer::DESCRIPTION1=>$this->message("prompt.info", _Guide::BUNDLE),
                GuideI18nPeer::DESCRIPTION2=>$this->message("prompt.un", _Guide::BUNDLE),
                GuidePeer::URL=>$this->message("prompt.url", _Guide::BUNDLE),
                CountryPeer::PRINTABLE_NAME=>$this->message("prompt.country", _Guide::BUNDLE),
                GuideI18nPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                GuideI18nPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                GuideI18nPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE)
            )
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th class="narrow"></th>

            <? /* Hide i18n if disabled */ ?>
            <? if($this->param(_Core::I18N)): ?>
                <th class="narrow" title="<?=$this->message("title.language", _Core::BUNDLE)?>">
                    <?=$this->message("label.language", _Core::BUNDLE)?>
                </th>
            <? endif; ?>

            <th>
                <?=$this->TH(
                    $this->guideListForm,        // ListForm
                    CountryPeer::PRINTABLE_NAME, // Sort Field
                    $this->message("prompt.country", _Guide::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->guideListForm,                          // ListForm
                    GuideI18nPeer::MODIFIED_DATE,                  // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->guideListForm,                         // ListForm
                    GuideI18nPeer::INSERT_DATE,                   // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->guideListForm,                       // ListForm
                    GuideI18nPeer::ACTIVE,                      // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>

            <? /* Hide i18n if disabled */ ?>
            <? if($this->param(_Core::I18N)): ?>
                <th class="narrow" title="<?=$this->message("title.language.available", _Core::BUNDLE)?>">
                    <?=$this->message("label.language.available", _Core::BUNDLE)?>
                </th>
            <? endif; ?>

            <th class="buttons"></th>
        </tr>

        <? foreach($this->guides($this->guideListForm)->getItems() as $guideI18n): ?>

            <? /* Display the default language guide */ ?>
            <tr class="ctrl">
                <td class="checkbox">
                    <input type="checkbox"
                           name="items[]"
                           value="<?=$guideI18n->getGuideI18nId()?>"
                           <?=in_array($guideI18n->getGuideI18nId(), $this->guideListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td>
                    <? if($guideI18n->getGuide()->getImageId() > 0): ?>
                    <a title="<?=$this->message("title.image", _Core::BUNDLE)?>" href="image?id=<?=$guideI18n->getGuide()->getImageId()?>">
                        <?=$this->thumbnail($guideI18n->getGuide()->getThumbnailId())?>
                    </a>
                    <? endif; ?>
                </td>

                <? /* Hide i18n if disabled */ ?>
                <? if($this->param(_Core::I18N)): ?>
                    <td title="<?=$this->message("title.language", _Core::BUNDLE)?>">

                        <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/".strtolower($guideI18n->getLanguage()->getCode()).".png")?>"
                             width="16" height="11" alt="<?=$guideI18n->getLanguage()->getName()?>"
                             title="<?=$guideI18n->getLanguage()->getName()?>" class="flag" />

                    </td>
                <? endif; ?>

                <td><?=$guideI18n->getGuide()->getCountry()->getPrintableName()?></td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$guideI18n->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$guideI18n->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$guideI18n->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$guideI18n->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($guideI18n->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>

                <? /* Hide i18n if disabled */ ?>
                <? if($this->param(_Core::I18N)): ?>
                    <td title="<?=$this->message("title.language.available", _Core::BUNDLE)?>">

                        <? /* Only show available languages when item language same as CMS default language) */ ?>
                        <? if($guideI18n->getLanguageCode() == $this->param(_Core::DEFAULT_LANGUAGE)) { ?>
                            <? foreach($guideI18n->getAvailableLanguages() as $language) { ?>
                                <a href="guide/edit?guideI18n->guideId=<?=$guideI18n->getGuideId()?>&amp;guideI18n->languageCode=<?=$language->getCode()?>">
                                    <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/".strtolower($language->getCode()).".png")?>"
                                         width="16" height="11"
                                         alt="<?=$language->getName()?>"
                                         title="<?=$this->message("title.translate.item", _Core::BUNDLE)?> (<?=$language->getName()?>)."
                                         class="flag" />
                                 </a>
                            <? } ?>
                        <? } ?>

                    </td>
                <? endif; ?>

                <td class="buttons">

                    <input type="button"
                           onclick="to('guide/edit?guideI18n->guideI18nId=<?=$guideI18n->getGuideI18nId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$guideI18n->getGuideI18nId()?>, '<?=get_class($this->guideListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

            <? /* Loop through the foreign languages when i18n enabled & language selectbox is on ALL */?>
            <? if($this->param(_Core::I18N) && strlen($this->guideListForm->getLanguage()) == 0 && strlen($this->guideListForm->getQuery()) == 0): ?>

                <?
                $i18nGuides = $guideI18n->getForeignGuideI18ns($this->param(_Core::DEFAULT_LANGUAGE));
                for($i=0; $i<count($i18nGuides); $i++) { ?>
                <tr class="ctrlsub">
                    <td class="checkbox">
                        <input type="checkbox"
                           name="items[]"
                           value="<?=$i18nGuides[$i]->getGuideI18nId()?>"
                           <?=in_array($i18nGuides[$i]->getGuideI18nId(), $this->guideListForm->getItems()) ? " checked=\"checked\"" : ""?> />
                    </td>
                    <td></td>
                    <td title="<?=$this->message("title.language", _Core::BUNDLE)?>">

                        <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/".strtolower($i18nGuides[$i]->getLanguage()->getCode()).".png")?>"
                             width="16" height="11"
                             alt="<?=$i18nGuides[$i]->getLanguage()->getName()?>"
                             title="<?=$this->message("title.translation", _Core::BUNDLE)?> (<?=$i18nGuides[$i]->getLanguage()->getName()?>)" />

                    </td>
                    <td class="translation">

                    </td>
                    <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$i18nGuides[$i]->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                        <?=$i18nGuides[$i]->getModifiedDate(_Core::FORMAT_DATE)?>
                    </td>
                    <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$i18nGuides[$i]->getInsertDate(_Core::FORMAT_DATETIME)?>">
                        <?=$i18nGuides[$i]->getInsertDate(_Core::FORMAT_DATE)?>
                    </td>
                    <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                        <?=$this->message("label." . ($i18nGuides[$i]->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                    </td>
                    <td></td>
                    <td class="buttons">

                        <input type="button"
                               onclick="to('guide/edit?guideI18n->guideI18nId=<?=$i18nGuides[$i]->getGuideI18nId()?>')"
                               class="button"
                               value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                        <input type="button"
                               onclick="del(<?=$i18nGuides[$i]->getGuideI18nId()?>, '<?=get_class($this->guideListForm)?>')"
                               class="button"
                               value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                    </td>
                </tr>
                <? } ?>

            <? endif; ?>

        <? endforeach; ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->guideListForm, // ListForm
            array(                // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->guideListForm,                         // ListForm
            $this->path()."guide/edit",                   // Add New URL
            $this->guides($this->guideListForm)->getRows() // The total amount of guides
        )?>


    </form>

<?=$this->footer()?>